#ifndef _FOC_SMO_H
#define _FOC_SMO_H


#include "foc_type.h"
#include "foc_filter.h"

typedef struct{
    PLL_t pll;

    SPEED_t speed;

    alphabeta_t Real_U;                         /* αβ轴输U出的电压 */
    alphabeta_t Real_I;                         /* αβ轴采集到的电流 */

    alphabeta_t Est_I;                          /* αβ轴估算的电流 */
    alphabeta_t Est_U;                          /* αβ轴估算的反电动势 */

    alphabeta_t Est_I_err;                      /* 观测的电流的误差 */

    alphabeta_t Est_V;                          /* αβ轴 V平面*/
    float h;                                    /* 滑模系数*/
    float Rs;                                   /* 相电阻 */
    float Ls;                                   /* 相电感 */
    float Ts;                                   /* 周期时间：s*/
    float Rs_Ls;
    float _1_Ls;
    float atan_theta;
    

}FOC_SMO_t;


void FOC_SMO_Init(FOC_SMO_t *foc_smo, float Rs, float Ls, float Ts, uint32_t pole_pairs, float max_speed);
void FOC_SMO_Angle_Cale(FOC_SMO_t *foc_smo);

void FOC_SMO_Angle_Calc(FOC_SMO_t *foc_smo, alphabeta_t Real_I, alphabeta_t Real_U);
void FOC_SMO_Speed_Calc(FOC_SMO_t *foc_smo);
void FOC_SMO_Clear(FOC_SMO_t *foc_smo);

#endif
